<template>
  <el-dialog
    append-to-body
    :before-close="cancel"
    :visible.sync="value">
    <template slot="title">
      手工调整
    </template>
    <el-form :model="form" :rules="refRules" ref="refForm" :label-width="'180px'">
      <el-form-item prop="adjust" label="手工调整金额">
        <el-input-number v-model="form.adjust" :controls="false" @keyup.enter.native="handlerSave('refForm')"></el-input-number>
        <el-tip style="color: red;">PS：调整的金额可以为负数</el-tip>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary"  @click="handlerSave('refForm')">确定</el-button>
    </div>
  </el-dialog>

</template>

<script>
  import {adjustCommission} from '@/services/api/commission'
  import {form} from '@/build'
  import ElTip from "@/components/Tip/index";

  export default {
    name: "adjust-commission-dialog",
    components: {ElTip},
    props:['value','id'],
    mixins:[form],
    data(){
      return{
        form:{
          id:this.id,
        },
        refRules:{
          adjust:{
            required:true,message:'金额为必填',trigger:'change'
          }
        }
      }
    },
    methods:{
      cancel(){
        this.$emit('input', false);
      },
      handlerSave(formName){
        this.$refs[formName].validate((valid) => {
          if(valid){
            this.doSave({action:'saveForm',form:'refForm'})
            this.cancel()
          }
        })
      }
    },
    computed: {
    },
    mounted(){
      this.bindSave(adjustCommission,'saveForm','form')
    }
  }
</script>

<style scoped>

</style>
